package zee.com.customviewexample.activity

import android.support.v4.app.Fragment
import android.support.v4.app.FragmentPagerAdapter
import com.zee.adapter.FragmentManagerAdapter
import com.zee.adapter.ViewPageFragmentAdapter
import kotlinx.android.synthetic.main.activity_zx_solidetab_layout.*
import zee.com.customviewexample.R
import zee.com.customviewexample.bean.TabBean
import zee.com.customviewexample.fragment.BaseFragment
import zee.com.customviewexample.fragment.FirstFragment
import zee.com.customviewexample.fragment.SecondFragment
import zee.com.customviewexample.fragment.TabFragment

class ZxSolidTabLayoutActivity : BaseActivity() {
    override fun getLayoutID(): Int {
        return R.layout.activity_zx_solidetab_layout
    }

    override fun initViews() {
//        exampleA()
//        exampleB()
        exampleC()
    }

    private fun exampleA() {
        val list = arrayListOf<BaseFragment>()
        list.add(FirstFragment())
        list.add(SecondFragment())

        id_fragment_zxSolid_view_page.adapter = object : FragmentPagerAdapter(supportFragmentManager) {
            override fun getItem(position: Int): Fragment {
                return list[position]
            }

            override fun getCount(): Int {
                return 2;
            }

            override fun getPageTitle(position: Int): CharSequence {
                return "界面$position"
            }
        }
        val title = arrayOf("ceshi", "ceshi2")
        id_fragment_zxSolid_layout.setTabData(title)
        id_fragment_zxSolid_layout.setViewPager(id_fragment_zxSolid_view_page)
//        id_fragment_zxSolid_layout.
    }

    private fun exampleB() {
        zxSolid_layout_c.setFragmentManagerAdapter(object : FragmentManagerAdapter(this) {
            override fun containerViewId(): Int {
                return R.id.fl_tabSolid
            }

            override fun getFragment(index: Int): Fragment {
                return TabFragment.newInstance(index)
            }

        })
    }

    private fun exampleC() {
        val list = java.util.ArrayList<TabBean>()
        list.add(TabBean("ItemA"))
        list.add(TabBean("ItemB"))
        list.add(TabBean("ItemC"))
        zxSolid_layout_d.setViewPageFragmentAdapter(object : ViewPageFragmentAdapter(supportFragmentManager, viewPage_a, list) {
            override fun getV4Fragment(index: Int): Fragment {
                return TabFragment.newInstance(index)
            }


        })
    }

}
